package amani.wechat.platform.services.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import amani.wechat.platform.services.IBookService;
import amani.wechat.platform.services.ICommonService;
import amani.wechat.platform.services.model.CompanyInfoEx;
import amani.wechat.platform.utils.MathUtils;
import amani.wechat.platform.webserviceClient.Companyinfo;

@Service("BookService")
public class BookService implements IBookService {

	@Resource(name="CommonService")
	ICommonService commonService ;
	@Override
	public List<CompanyInfoEx> getnearbystore(double  xcoordinate, double  ycoordinate) {
		List<Companyinfo> companyInfoList=	commonService.loadAllCompanyinfo();
		List<CompanyInfoEx> result=new ArrayList<CompanyInfoEx>();
		for(int i=0;i<companyInfoList.size();i++){
			Companyinfo companyInfo= companyInfoList.get(i);
			CompanyInfoEx companyInfoEx=new CompanyInfoEx(companyInfo); 
			companyInfoEx.setMeters(MathUtils.Distance(ycoordinate, xcoordinate,Double.parseDouble( companyInfoEx.getYcoordinate()), Double.parseDouble( companyInfoEx.getXcoordinate())));
			result.add(companyInfoEx);
		} 
		return result;
	}
	
 

}
